home *** CD-ROM | disk | FTP | other *** search
/ com!online 2005 May / com_0505_1.iso / opensource / top10 / amc_install.exe / {app} / Scripts / DVDZone2 (FR).ifs < prev    next >
Encoding:
Text File  |  2005-02-01  |  8.3 KB  |  263 lines

  1. // GETINFO SCRIPTING
  2. // DVDZone2 (Franτais)
  3.  
  4. (***************************************************
  5.  *  Movie importation script for:                  *
  6.  *      DVD Zone 2, http://www.dvdzone2.com        *
  7.  *                                                 *
  8.  *  Rewritten by Antoine Potten                    *
  9.  *  Adapted by Candyghost                          *
  10.  *  Fixed Lenght + added subtitles                 *
  11.  *                                                 *
  12.  *  For use with Ant Movie Catalog 3.4.3           *
  13.  *  www.antp.be/software/moviecatalog              *
  14.  *                                                 *
  15.  *  This program is free software; you can         *
  16.  *  redistribute it and/or modify it under the     *
  17.  *  terms of the GNU General Public License as     *
  18.  *  published by the Free Software Foundation;     *
  19.  *  either version 2 of the License, or (at your   *
  20.  *  option) any later version.                     *
  21.  ***************************************************)
  22.  
  23. program DVDZone2_FR;
  24. var
  25.   MovieName: string;
  26.  
  27. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  28. var
  29.   i: Integer;
  30. begin
  31.   result := -1;
  32.   if StartAt < 0 then
  33.     StartAt := 0;
  34.   for i := StartAt to List.Count-1 do
  35.     if Pos(Pattern, List.GetString(i)) <> 0 then
  36.     begin
  37.       result := i;
  38.       Break;
  39.     end;
  40. end;
  41.  
  42. procedure AnalyzePage(Address: string);
  43. var
  44.   Line, MovieItem, MovieTitle, MovieAddress: string;
  45.   TitlePos, BeginPos, EndPos: Integer;
  46.   List: TStringList;
  47. begin
  48.   Line := GetPage(Address);
  49.   PickTreeClear;
  50.   if Pos('</b> : 0 item(s) found<br>', Line) = 0 then
  51.   begin
  52.     PickTreeAdd('Search results from DVDZone2', '');
  53.     BeginPos := Pos('<!-- CENTRAL TABLE -->', Line);
  54.     EndPos := Pos('<!-- /CENTRAL TABLE -->', Line);
  55.     Line := Copy(Line, BeginPos, EndPos - BeginPos);
  56.     List := TStringList.Create;
  57.     repeat
  58.       TitlePos := Pos('<a href="http://www.dvdzone2.com/dvd/detail.asp', Line);
  59.       if TitlePos > 0 then
  60.       begin
  61.         Delete(Line, 1, TitlePos);
  62.         MovieItem := Copy(Line, 1, Pos('add2basket', Line));
  63.         BeginPos := Pos('"', MovieItem) + 1;
  64.         EndPos := Pos('" class', MovieItem);
  65.         MovieAddress := Copy(MovieItem, BeginPos, EndPos - BeginPos);
  66.         BeginPos := Pos('">', MovieItem) + 2;
  67.         EndPos := Pos('</a>', MovieItem);
  68.         MovieTitle := Copy(MovieItem, BeginPos, EndPos - BeginPos);
  69.         List.Text := MovieItem;
  70.         MovieItem := Trim(List.GetString(3));
  71.         if MovieItem <> '' then
  72.           MovieTitle := MovieTitle + ' [' + MovieItem + ']';
  73.         MovieItem := Trim(List.GetString(9));
  74.         if MovieItem <> '' then
  75.           MovieTitle := MovieTitle + ' (' + MovieItem + ')';
  76.         PickTreeAdd(MovieTitle, MovieAddress);
  77.         Delete(Line, 1, 25);
  78.       end;
  79.     until TitlePos = 0;
  80.     List.Free;
  81.   end;
  82.   if PickTreeExec(Address) then
  83.     AnalyzeMoviePage(Address);
  84. end;
  85.  
  86. procedure AnalyzeMoviePage(Address: string);
  87. var
  88.   Line, Value, FullValue: string;
  89.   LineNr: Integer;
  90.   BeginPos, EndPos: Integer;
  91.   Page: TStringList;
  92. begin
  93.   Line := GetPage(Address);
  94.   BeginPos := Pos('<!-- CENTRAL TABLE -->', Line);
  95.   EndPos := Pos('<!-- /CENTRAL TABLE -->', Line);
  96.   Line := Copy(Line, BeginPos, EndPos - BeginPos);
  97.  
  98.   // title
  99.   BeginPos := Pos('<span class="detail-title">', Line);
  100.   Delete(Line, 1, BeginPos);
  101.   BeginPos := Pos('>', Line) + 1;
  102.   EndPos := Pos('</', Line);
  103.   Value := Copy(Line, BeginPos, EndPos - BeginPos);
  104.   HTMLDecode(Value);
  105.   SetField(fieldTranslatedTitle, Value);
  106.  
  107.   // nbr de disques
  108.   BeginPos := Pos('<b>Nombre de disque(s)</b>: ', Line);
  109.   Delete(Line, 1, BeginPos);
  110.   BeginPos := Pos(';', Line) + 1;
  111.   EndPos := Pos('<br', Line);
  112.   Value := Copy(Line, BeginPos, EndPos - BeginPos);
  113.   HTMLDecode(Value);
  114.   SetField(fieldDisks, Value);
  115.  
  116.   // picture
  117.   BeginPos := Pos('http://www.dvdzone2.com/pictures/big/', Line);
  118.   if BeginPos > 0 then
  119.   begin
  120.     Delete(Line, 1, BeginPos - 1);
  121.     EndPos := Pos('"', Line);
  122.     Value := Copy(Line, 1, EndPos - 1);
  123.     GetPicture(Value, False);
  124.   end;
  125.  
  126.   // description
  127.   BeginPos := Pos('<p>', Line);
  128.   Delete(Line, 1, BeginPos + 2);
  129.   EndPos := Pos(#13, Line);
  130.   Value := StringReplace(Copy(Line, 1, EndPos - 1), '<p>', #13#10#13#10);
  131.   HTMLRemoveTags(Value);
  132.   HTMLDecode(Value);
  133.   SetField(FieldDescription, Value);
  134.  
  135.   // rating
  136.   BeginPos := Pos('note globale', Line);
  137.   if BeginPos > 0 then
  138.   begin
  139.     Delete(Line, 1, BeginPos);
  140.     BeginPos := Pos('<b>', Line);
  141.     if BeginPos > 0 then
  142.     begin
  143.       BeginPos := BeginPos + 3;
  144.       EndPos := Pos(',', Line);
  145.       Value := Copy(Line, BeginPos, EndPos - BeginPos);
  146.       SetField(fieldRating, Value);
  147.     end;
  148.   end;
  149.  
  150.   Page := TStringList.Create;
  151.   BeginPos := Pos('<td height="120" width="50%" class="dvd-detail-border-c" valign="top" align="left">', Line);
  152.   Delete(Line, 1, BeginPos);
  153.   EndPos := Pos('</table>', Line);
  154.   Page.Text := Copy(Line, 1, EndPos);
  155.  
  156.   // titre original
  157.   SetField(fieldOriginalTitle, GetInfo('<b>Titre original', Page));
  158.  
  159.   // director
  160.   SetField(fieldDirector, GetInfo('<b>RΘalisateur(s)', Page));
  161.  
  162.   // actors
  163.   SetField(fieldActors, StringReplace(GetInfo('<b>Acteurs', Page), ' - ', ', '));
  164.  
  165.   // country
  166.   SetField(fieldCountry, GetInfo('<b>Pays', Page));
  167.  
  168.   // year
  169.   SetField(fieldYear, GetInfo('<b>AnnΘe', Page));
  170.  
  171.   // studio (producer)
  172.   SetField(fieldProducer, GetInfo('<b>Studio', Page));
  173.  
  174.   // category
  175.   SetField(fieldCategory, GetInfo('<b>Genres', Page));
  176.  
  177.   // format vidΘo
  178.   SetField(fieldVideoFormat, GetInfo('<b>Format vidΘo', Page));
  179.  
  180.   // length
  181.   Value := GetInfo('<b>DurΘe', Page);
  182.   EndPos := Pos('min', Value);
  183.   SetField(fieldLength, Copy(Value, 1, EndPos - 2));
  184.  
  185.   // Sous-titres
  186.   BeginPos := Pos('<span class="px11">SOUS-TITRES</span>', Line);
  187.     Delete(Line, 1, BeginPos);
  188.   BeginPos := Pos('</td>', Line);
  189.     Delete(Line, 1, BeginPos);
  190.   BeginPos := Pos('<td class=""dvd-detail-border-left"" align=""center"" valign=""middle"" colspan=""2"">', Line);
  191.     Delete(Line, 1, BeginPos + 96);
  192.   Value := Copy(Line , BeginPos  , Length(Line));
  193.   EndPos := Pos('</td>', Value);
  194.   Value := Copy(Value , 1, EndPos -5);
  195.     HTMLRemoveTags(Value);
  196.     HTMLDecode(Value);
  197.   SetField(fieldSubtitles, Value);
  198.  
  199.   // special features (comments)
  200.   BeginPos := Pos('<span class="detail-title">Les Bonus</span>', Line);
  201.   Delete(Line, 1, BeginPos);
  202.   EndPos := Pos('</table>', Line);
  203.   Delete(Line, EndPos, Length(Line));
  204.   FullValue := '';
  205.   repeat
  206.     BeginPos := Pos('</tr>', Line);
  207.     Delete(Line, 1, BeginPos);
  208.     BeginPos := Pos('<tr>', Line);
  209.     if BeginPos > 0 then
  210.     begin
  211.       BeginPos := Pos('<b>', Line);
  212.       if BeginPos > 0 then
  213.       begin
  214.         Value := Copy(Line, BeginPos + 3, Length(Line));
  215.         EndPos := Pos(#10, Value);
  216.         Value := StringReplace(Copy(Value, 1, EndPos - 1), '<br>', ' ');
  217.         HTMLRemoveTags(Value);
  218.         HTMLDecode(Value);
  219.         FullValue := FullValue + '- ' + Value + #13#10;
  220.       end;
  221.     end;
  222.   until (Pos('<tr>', Line) = 0) or (Pos('<b>', Line) = 0);
  223.   if FullValue <> '' then
  224.     SetField(fieldComments, 'Bonus:' + #13#10 + FullValue);
  225.  
  226.   Page.Free;
  227.   DisplayResults;
  228. end;
  229.  
  230. function GetInfo(Name: string; Page: TStringList): string;
  231. var
  232.   LineNr, BeginPos, EndPos: Integer;
  233.   Value, Line: string;
  234. begin
  235.   LineNr := FindLine(Name, Page, 0);
  236.   if LineNr > 0 then
  237.   begin
  238.     Line := Page.GetString(LineNr);
  239.     BeginPos := Pos(': ', Line) + 7;
  240.     EndPos := Pos('<br>', Line);
  241.     Value := Copy(Line, BeginPos, EndPos - BeginPos);
  242.     HTMLRemoveTags(Value);
  243.     HTMLDecode(Value);
  244.     Result := Value;
  245.   end else
  246.     Result := '';
  247. end;
  248.  
  249. begin
  250.   if CheckVersion(3,4,0) then
  251.   begin
  252.     MovieName := GetField(fieldOriginalTitle);
  253.     if MovieName = '' then
  254.       MovieName := GetField(fieldTranslatedTitle);
  255.     if Input('DVDZone2 (FR) Import', 'Entrez le titre du film:', MovieName) then
  256.     begin
  257.       GetPage('http://www.dvdzone2.com/language.asp?id=fra&dest=dvd');
  258.       AnalyzePage('http://www.dvdzone2.com/dvd/search.asp?t=1&kw=' + UrlEncode(MovieName) + '&kwt=t&pl=all');
  259.     end;
  260.   end else
  261.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
  262. end.
  263.